
/* Initial beliefs and rules */
/* BELIEFS */


/* RULES */



/* initial DESIRES */
!search_corral.


/* INTENTIONS (PLANS AND ACTIONS) */
+!find_pos : true
	<- .wait("+pos(_,_,_)").
	
+!find_pos_corral : true
	<- .wait("+corral(_,_,_,_)").

+!search_corral : not pos(_,_,_)
	<- !find_pos;
	   !search_corral.

+!search_corral : pos(_,_,_) & not corral(_,_,_,_)
	<- !find_pos_corral;
	   !search_corral.

+!search_corral : pos(_,_,_) & corral(_,_,_,_)
  <- !goto_corral_position.

+!goto_corral_position : pos(_,_,_) & corral(Px,Py,Cx,Cy)
  <- +target(Cy,Cx);
     !move.

+!move : pos(X,Y,_) & not target(_,_)
  <- .print("move random");
     br.poli.ecomp.sma.massim.action.RandomPos(X,Y,NewX,NewY);
     br.poli.ecomp.sma.massim.action.FindDirection(X,Y,NewX,NewY,Direction);
     moveTo(Direction);
     .wait("+pos(_,_,_)");
     !move.

+!move : pos(X,Y,_) & target(Cx,Cy) & Cx \== X & Cy \== Y
  <- .print("move to target");
     br.poli.ecomp.sma.massim.action.FindPos(X,Y,Cx,Cy,Direction);
 //    br.poli.ecomp.sma.massim.action.FindDirection(X,Y,NewX,NewY,Direction);
     moveTo(Direction);
     .wait("+pos(_,_,_)");
     !move.

+!move : pos(X,Y,_) & target(Cx,Cy) & Cx == X & Cy == Y
  <- .print("target");
     -target(Cx,Cy).
     